<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>天天生鲜-用户中心</title>
	<link rel="stylesheet" type="text/css" href="${path}/static/front/css/reset.css">
	<link rel="stylesheet" type="text/css" href="${path}/static/front/css/main.css">
</head>
<body>
	<div class="header_con">
		<div class="header">
			<div class="welcome fl">欢迎来到天天生鲜!</div>
			<div class="fr">
					<c:if test="${user!=null}">
						<div class="user_link fl">
							欢迎您：<em style="color:#CC0000;">${user.username}</em>
							<span>|</span>
							<a href="user_center_info.html">用户中心</a>
							<span>|</span>
							<a href="cart.html">我的购物车</a>
							<span>|</span>
							<a href="user_center_order.html">我的订单</a>
						</div>
					 </c:if>
					 <c:if test="${user==null}">
						<div class="login_btn fl">
							<a href="javascript:void(0);" onclick="loginSubmit()">登录</a>
							<span>|</span>
							<a href="${path}/register.jsp">注册</a>
						</div>
						<div class="user_link fl">
							<span>|</span>
							<a href="user_center_info.html">用户中心</a>
							<span>|</span>
							<a href="cart.html">我的购物车</a>
							<span>|</span>
							<a href="user_center_order.html">我的订单</a>
						</div>
					 </c:if>
				</div>
		</div>		
	</div>

	<div class="search_bar clearfix">
		<a href="${path}/index.jsp" class="logo fl"><img src="${path}/static/front/images/logo.png"></a>
		<div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;用户中心</div>
		<div class="search_con fr">
			<input type="text" class="input_text fl" name="" placeholder="搜索商品">
			<input type="button" class="input_btn fr" name="" value="搜索">
		</div>		
	</div>

	<div class="main_con clearfix">
		<div class="left_menu_con clearfix">
			<h3>用户中心</h3>
			<ul>
				<li><a href="user_center_info.jsp">· 个人信息</a></li>
				<li><a href="${path}/order/getUserCenterOrder.shtml">· 全部订单</a></li>
				<li><a href="javascript:;" class="active">· 收货地址</a></li>
			</ul>
		</div>
		<div class="right_content clearfix">
				<h3 class="common_title2">收货地址</h3>
				<div class="site_con">
					<dl>
						<dt>当前地址：</dt>
						<dd>
							<span>${shipping.receiverProvince}</span>
							<span>${shipping.receiverCity}</span>
							<span>${shipping.receiverDistrict}</span>
							<span>(${shipping.receiverName} 收)</span>
							<span id="tel">${shipping.receiverPhone}</span>
						</dd>
					</dl>					
				</div>
				<h3 class="common_title2">编辑地址</h3>
				<div class="site_con">
					<form id="shippingSite_form"  method="post" onsubmit="return false">
						<div class="form_group">
							<label>收件人：</label>
							<input type="text" name="receiver" id="receiver">
						</div>
						
						<div class="form_group">
							<label>省：</label>
							<select id="provinceId" onchange="selectCity(this)">
								<option>--请选择--</option>
							</select>
						</div>
						
						<div class="form_group">
							<label>市：</label>
							<select id="cityId" onchange="selectArea(this)">
								<option>--请选择--</option>
							</select>
						</div>
						
						<div class="form_group">
							<label>区县：</label>
							<select id="areaId">
								<option>--请选择--</option>
							</select>
						</div>

						<div class="form_group form_group2">
							<label>详细地址：</label>
							<textarea name="detailAdd" class="site_area" id="detailAdd"></textarea>
						</div>
						<div class="form_group">
							<label>邮编：</label>
							<input type="text" name="zip" id="zip">
						</div>
						<div class="form_group">
							<label>手机：</label>
							<input type="text" name="phone" id="phone">
						</div>

						<input type="submit" name="" value="提交" class="info_submit" onclick="submitShippingSite()">
					</form>
				</div>
		</div>
	</div>



	<div class="footer">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>		
		</div>
		<p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
		<p>电话：010-****888    京ICP备*******8号</p>
	</div>
	
	<script src="${path}/static/lib/jquery-1.11.3.js" type="text/javascript" charset="utf-8"></script>
    <script src="${path}/static/lib/layer/layer.js" type="text/javascript" charset="utf-8"></script>
    <script src="${path}/static/lib/mylayer.js" type="text/javascript" charset="utf-8"></script>
    <script src="${path}/static/lib/myUtil.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		function submitShippingSite(){
			$.ajax({
				url:"${path}/shipping/editShippingSite.shtml",
				data:$("#shippingSite_form").serialize(),
				type:"post",
				dataType:"json",
				success:function(jsonObj){
					if(jsonObj.code == myUtil.SUCCESS) {
						mylayer.successMsg(jsonObj.msg);
					} else {
						mylayer.errorMsg(jsonObj.msg);
					}
				}
			});
		}
		
		$(function(){
			
			$.ajax({
				url:"${path}/shipping/editShippingSite.shtml",
				data:$("#shippingSite_form").serialize(),
				type:"post",
				dataType:"json",
				success:function(jsonObj){
					if(jsonObj.code == myUtil.SUCCESS) {
						mylayer.successMsg(jsonObj.msg);
					} else {
						mylayer.errorMsg(jsonObj.msg);
					}
				}
			});
			
			$("#tel").html("${shipping.receiverPhone}".substring(0,3)+"*****"+"${shipping.receiverPhone}".substring(8,11));
		})
		
		$(function(){
			$.post{
				"${path}/shipping/selectShippingReceiverProvince.shtml",
				function(jsonArray){
					$(jsonArray).each(function(){
						var html = "<option value='"+this.id+"'>"+this.province+"</option>";
						$("#provinceId").append(html);
					});
				},
				"json"
			}
		})
	</script>
</body>
</html>